//package com.hnguigu.realm;
//
//import com.hnguigu.pojo.Users;
//import com.hnguigu.service.AccService;
//import org.apache.shiro.authc.AuthenticationException;
//import org.apache.shiro.authc.AuthenticationInfo;
//import org.apache.shiro.authc.AuthenticationToken;
//import org.apache.shiro.authc.SimpleAuthenticationInfo;
//import org.apache.shiro.authz.AuthorizationInfo;
//import org.apache.shiro.crypto.hash.SimpleHash;
//import org.apache.shiro.realm.AuthorizingRealm;
//import org.apache.shiro.subject.PrincipalCollection;
//import org.apache.shiro.util.ByteSource;
//import org.springframework.beans.factory.annotation.Autowired;
//
//public class Sha1Realm extends AuthorizingRealm {
//    @Autowired
//    AccService service;
//    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
//        return null;
//    }
//
//    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
//        //获取当前账号
//        Object principal = authenticationToken.getPrincipal();
//        System.out.println("SHA1reamls账号为"+principal);
//        Users users = service.selectByPrimaryKey((String) principal);
////        System.out.println("根据用户名为11111111"+users);
//        //计算盐值
//        ByteSource bytes = ByteSource.Util.bytes(principal);
//        System.out.println("SHA1用户名的盐值"+bytes);
//        //获取当前密码
//
//        SimpleAuthenticationInfo simple = new SimpleAuthenticationInfo(principal,users.getPassword(),bytes,getName());
//        System.out.println("SHA1realm的simple"+simple);
//        return simple;
//    }
//    public static void main(String[] args) {
//      //  SimpleHash hash = new SimpleHash("MD5","1234","tome",1024);
//        SimpleHash hash1 = new SimpleHash("SHA1","123","nm",1024);
//        System.out.println(hash1);
//    }
//}
